﻿<!-- 考试管理-名单管理-补考 -->
<!--<style>
    .el-table__body tr.current-row > td {
        background: #9cdcc2 !important;
    }
</style>-->
<template>
    <div>
        <!-- 添加按钮 -->
        <div class="btn-add">
            <button type="button" class="btn btn-success btn-lg" v-if="isgly" @click="scmd()"><i class="iconfont icon-chenggong ft12 mr5"></i>生成名单</button>
            <button type="button" class="btn btn-info btn-lg" @click="setzg()"><i class="iconfont icon-chenggong ft12 mr15"></i>管理资格</button>
            <button type="button" class="btn btn-danger btn-lg" @click="qxbk()"><i class="iconfont icon-chexiao ft12 mr5"></i>删除名单</button>


        </div>
        <!-- 按条件选择 -->

        <el-row :gutter="20" style="height:100px;padding:20px;">
            <el-col :span="3">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">考试类别</button>
                    </div>
                    <el-select placeholder="考试类别" size="mini" v-model="query.lx" class="form-control filter" style="height: 34px;padding:0px">
                        <el-option label="补考" value="补考"></el-option>
                    </el-select>

                </div>
            </el-col>
            <el-col :span="4">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">校区</button>
                    </div>
                    <base-xiaoq :pzoption="query.xiaoq"></base-xiaoq>

                </div>
            </el-col>
            <el-col :span="4">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">考试学期</button>
                    </div>
                    <base-xq :pzoption="query.xq"></base-xq>
                </div>
            </el-col>
            <el-col :span="6">
                <div class="input-group" style="margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">班级系部</button>
                    </div>
                    <base-xb :pzoption="query.xb" isqx isjx isdx></base-xb>
                </div>
            </el-col>
            <el-col :span="4">

            </el-col>
            <el-col :span="6">
            </el-col>
        </el-row>

        <el-row :gutter="20" style="padding:20px;   padding-top: 0px;">
            <el-col :span="8">

                <div class="input-group" style="width:520PX;margin-bottom:10PX;">
                    <div class="input-group-btn">
                        <button type="button" style="min-width:120PX;height: 34px;" class="btn btn-info  dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">搜索</button>
                        <!--<ul class="dropdown-menu">
                            <li><a href="#">补考课程</a></li>
                            <li><a href="#">上课老师</a></li>

                        </ul>-->
                    </div>
                    <el-input style="height: 34px;border-left-width: 0px;width:250px" size="medium" placeholder="输入课程搜索数据" v-model="seastrkc" clearable></el-input>

                    <!--<input type="text" class="form-control" style="height: 34px;width:65%;border-left-width: 0px;" placeholder="输入关键字搜索数据">-->

                </div>
                <pl-table :data="comkcdata" class="qjTable" v-loading="loading" @selection-change="selchangekc" height="500px" :row-style="{height:'20px'}" :cell-style="{padding:'0px'}" element-loading-background="rgba(0, 0, 0, 0.8)" stripe border fit use-virtual big-data-checkbox>
                    <pl-table-column type="selection" width="45" fixed="left">
                    </pl-table-column>
                    <pl-table-column type="index" width="50" fixed="left"> </pl-table-column>

                    <pl-table-column prop="kcmc">
                        <template slot="header" slot-scope="scope">
                            <div style="padding:0px">
                                补考课程
                            </div>

                        </template>
                        <template slot-scope="scope">
                            <span>【{{scope.row.kcdm}}】{{scope.row.kcmc}}</span>
                        </template>
                    </pl-table-column>

                    <pl-table-column prop="score" label="总人数" width="120" sortable>
                        <template slot-scope="scope">
                            <el-tag type="success" disable-transitions>{{scope.row.score}}</el-tag>
                        </template>
                    </pl-table-column>

                </pl-table>
            </el-col>
            <el-col :span="16">
                <base-table :pzoption="tableop" @selection-change="rychange">
                </base-table>
            </el-col>
        </el-row>


        <div class="modal fade dx" id="DModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 1100px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">
                            生成补考名单
                        </h4>
                    </div>
                    <div class="modal-body">
                        <el-alert show-icon style="width:96%;margin:20px" title="注意事项" type="warning" description="通过设置相关属性，生成待补考学生名单,以下情况均属于待补考（总评成绩低于60分，缺考）,重新生成会删除历史数据,请谨慎操作">
                        </el-alert>
                        <el-row :gutter="12" style="padding: 0 20px;display:none">
                            <el-col :span="12">
                                <el-card shadow="hover">
                                    安排班级：{{bjs}}
                                </el-card>
                            </el-col>
                            <el-col :span="6">
                                <el-card shadow="hover">
                                    安排课程：{{kcs}}
                                </el-card>
                            </el-col>
                            <el-col :span="6">
                                <el-card shadow="hover">
                                    安排考生数量:{{kss}}
                                </el-card>
                            </el-col>
                        </el-row>
                        <el-row :gutter="12" style="padding: 0 20px;">
                            <el-col :span="6">
                                <div class="input-group" style="margin-bottom:10PX;">
                                    <div class="input-group-btn">
                                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-default  dropdown-toggle">考试类别</button>
                                    </div>
                                    <el-select placeholder="考试类别" size="mini" v-model="query.lx" class="form-control filter" style="height: 34px;padding:0px">
                                        <el-option label="补考" value="补考"></el-option>
                                    </el-select>

                                </div>
                            </el-col>
                            <el-col :span="6">
                                <div class="input-group" style="margin-bottom:10PX;">
                                    <div class="input-group-btn">
                                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-default    dropdown-toggle">考试学期</button>
                                    </div>
                                    <input type="text" v-model="query.xq.value" class="form-control" />

                                </div>
                            </el-col>

                            <el-col :span="6">
                                <div class="input-group" style="margin-bottom:10PX;">
                                    <div class="input-group-btn">
                                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary  dropdown-toggle">统计成绩学期</button>
                                    </div>
                                    <base-xq :pzoption="cjxq"></base-xq>

                                </div>
                            </el-col>
                            <el-col :span="6">

                            </el-col>
                        </el-row>
                        <el-row :gutter="12" style="padding: 0 20px;margin-top:10px">
                            <el-col :span="22">
                                <div class="input-group" style="margin-bottom:10PX;">
                                    <div class="input-group-btn">
                                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary    dropdown-toggle">年级</button>
                                    </div>
                                    <base-bj :pzoption="bj" isdx></base-bj>

                                </div>
                            </el-col>
                            <el-col :span="2">

                            </el-col>
                        </el-row>
                        <el-row :gutter="12" style="padding: 0 20px;margin-top:10px">

                            <el-col :span="22">
                                <div class="input-group" style="margin-bottom:10PX;">
                                    <div class="input-group-btn">
                                        <button type="button" style="height: 34px;min-width:80PX" class="btn btn-primary    dropdown-toggle">课程类别</button>
                                    </div>
                                    <base-kclb :pzoption="kclb" isdx></base-kclb>
                                </div>
                            </el-col>
                            <el-col :span="2">

                            </el-col>
                        </el-row>
                        <el-row :gutter="12" style="padding: 0 20px;margin-top:10px;display:none">

                            <el-col :span="4">
                                <el-switch v-model="islxcj"
                                           active-text="统计累计成绩"
                                           active-value="Y"
                                           inactive-value="N">
                                </el-switch>
                            </el-col>
                            <el-col :span="20">

                            </el-col>
                        </el-row>
                        <el-row :gutter="12" style="padding: 0 20px;margin-top:10px;">

                            <el-col :span="6">

                            </el-col>
                            <el-col :span="12">
                                <el-button type="success" @click="SaveData">生成名单</el-button>

                            </el-col>
                            <el-col :span="6">

                            </el-col>
                        </el-row>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
            </div>
        </div>

        <!-- 表格 -->
        <div class="modal fade dx" id="ZGModal" role="dialog">
            <div class="modal-dialog" role="document" style="width: 1100px">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">
                            设置补考资格
                        </h4>
                    </div>
                    <div class="modal-body" style="min-height: 100px;text-align: center; margin-top: 50PX;">
                        <el-radio-group v-model="bkzg">
                            <el-radio :label="0">无资格</el-radio>
                            <el-radio :label="1">有资格</el-radio>
                        </el-radio-group>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-info" @click="SaveZGData()">确认</button>

                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    module.exports = {
        props: ['pdata'],
        components: {
            'base-table': httpVueLoader('/ViewV5/Base/Vue/Table.vue'),
            'base-xq': httpVueLoader('/ViewV5/AppPage/QJJW/component/conxq.vue'),
            'base-xb': httpVueLoader('/ViewV5/AppPage/QJJW/component/conxb.vue?v=2'),
            'base-kclb': httpVueLoader('/ViewV5/AppPage/QJJW/component/conkclb.vue'),
            'base-bj': httpVueLoader('/ViewV5/AppPage/QJJW/component/conbj.vue'),
            'base-xiaoq': httpVueLoader('/ViewV5/AppPage/QJJW/component/conxiaoq.vue'),


        },
        data: function () {
            return {
                seastrkc: "",
                kcdm: "",
                jssl: 0,
                isgly: false,
                allxsdata: [],//学生数据
                allkcdata: [],//所有课程
                sjdata: [],//时间
                jsdata: [],//教室
                selsj: {},//选中时间
                seljs: {},//选中教师
                rselsj: "",
                rseljs: "",
                loading: false,
                bkzg: 1,//补考资格
                query: {
                    lx: "补考",
                    qrzt: "",
                    apqk: "",
                    xb: { value: [] },
                    xq: { value: "" },
                    xiaoq: { value: "" },

                },
                js: { value: "" },
                bj: { value: [] },
                kclb: { value: [] },
                seljc: { jcmc: "", isbn: "" },
                cjxq: { value: "" },//成绩学期
                islxcj: "N",//累计成绩
                tableop: {
                    title: "考生信息",
                    issel: true,
                    iscz: false,
                    height: 480,
                    isxh: true,
                    dataset: [],
                    loading: false,
                    multipleSelection: [],
                    collist: [
                        { colid: "kcmc", colname: "课程名称", isshow: true, istip: true },
                        { colid: "kcdm", colname: "课程代码", isshow: false, istip: true },
                        { colid: "jsmc", colname: "上课老师", isshow: true, istip: true },
                        { colid: "kcxbmc", colname: "课程系部", isshow: false, istip: true },
                        { colid: "zbmc", colname: "班级系部", isshow: false, istip: true },
                        { colid: "bj", colname: "班级", isshow: true, istip: true },
                        { colid: "xh", colname: "学号", isshow: true, istip: true, nosort: true },
                        { colid: "xm", colname: "姓名", isshow: true, istip: true, nosort: true },
                        { colid: "kscj", colname: "考试成绩", isshow: true, istip: true },
                        { colid: "pscj", colname: "平时成绩", isshow: false, istip: true },
                        { colid: "qzcj", colname: "期中成绩", isshow: false, istip: true },
                        { colid: "qmcj", colname: "期末成绩", isshow: false, istip: true },
                        {
                            colid: "sfjk", colname: "考试资格", isshow: true, istip: true, rowfun: function (rowdata) {
                                if (rowdata.sfjk) {
                                    return "<span style='color: #67C23A;'>有资格</span>";
                                } else {
                                    return "<span style='color: #F56C6C;'>无资格</span>";

                                }
                            }
                        },
                        { colid: "bklb", colname: "补考类别", isshow: true, istip: true }
                    ]
                }
            }
        },
        computed: {
            kss: function () {
                return this.tableop.multipleSelection.length;
            },
            bjs: function () {
                var bjs = "";
                _.forEach(this.tableop.multipleSelection, function (obj) {
                    if (bjs.indexOf(obj.bj) == -1) {
                        bjs = bjs + obj.bj + ",";
                    }
                })
                return bjs;
            },
            kcs: function () {
                var kcs = "";
                _.forEach(this.tableop.multipleSelection, function (obj) {
                    if (kcs.indexOf(obj.kcmc) == -1) {
                        kcs = kcs + obj.kcmc + ",";
                    }
                })
                return kcs;
            },
            comkcdata: function () {
                var pro = this;
                if (pro.seastrkc) {
                    return _.filter(pro.allkcdata, function (obj) {
                        return (obj.kcmc.indexOf(pro.seastrkc) > -1 );
                    })
                } else {
                    return pro.allkcdata;
                }
            }
        },
        methods: {
            filterTag(value, row) {
                return row.zt == value;
            },
            selchangekc: function (val, taa) {
                var pro = this;
                var kcs = [];
                for (var i = 0; i < val.length; i++) {
                    kcs.push(val[i].kcdm);
                }
                if (kcs.length >= 0) {
                    var xsdatas = pro.allxsdata.filter(data => {
                        var bl = false;
                        for (var i = 0; i < kcs.length; i++) {
                            if (data["kcdm"] == kcs[i] ) {
                                bl = true;
                                break;
                            }
                        }
                        return bl;
                    })
                    pro.tableop.dataset = xsdatas;
                }
            },
            rychange(val) {
                this.tableop.multipleSelection = val;
            },
            seljse: function (rowdata) {
                this.seljs = rowdata;
            },
            scmd: function () {
                $('#DModal').modal('show');
            },
            setzg: function () {
                $('#ZGModal').modal('show');
            },
            SaveZGData: function () {
                var pro = this;
                var ids = [];
                for (var i = 0; i < pro.tableop.multipleSelection.length; i++) {
                    ids.push(pro.tableop.multipleSelection[i].idn);
                }
                if (ids.length == 0) {
                    pro.$notify.error({
                        title: '错误',
                        message: '至少需要选择一条数据才能操作'
                    });
                    return;
                }
                $.getJSON('/API/VIEWAPI.ashx?Action=KSGL_SETBKZG', { ids: ids.join(), bkzg: pro.bkzg }, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        pro.$notify({
                            title: '成功',
                            message: '操作成功',
                            type: 'success'
                        });
                        pro.querydata();
                        $('#ZGModal').modal('hide');
                    }
                })

            },
            qxbk: function () {
                var pro = this;
                var ids = [];
                for (var i = 0; i < pro.tableop.multipleSelection.length; i++) {
                    ids.push(pro.tableop.multipleSelection[i].idn);
                }
                if (ids.length == 0) {
                    this.$notify.error({
                        title: '错误',
                        message: '至少需要选择一条数据才能操作'
                    });
                    return;
                }
                pro.$confirm('是否确认要删除该名单?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.getJSON('/API/VIEWAPI.ashx?Action=KSGL_DELBKMD', { ids: ids.join() }, function (resultData) {
                        if (!resultData.ErrorMsg) {
                            pro.$notify({
                                title: '成功',
                                message: '操作成功',
                                type: 'success'
                            });
                            pro.querydata();


                        }
                    })
                }).catch(() => {
                    pro.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });



            },
            SaveData: function () {
                var pro = this;
                pro.loading = true;
                pro.$confirm('重新生成会删除历史数据, 确定要生成补考名单吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    $.getJSON('/API/VIEWAPI.ashx?Action=KSGL_SCBKMD', { xq: pro.query.xq.value, cjxq: pro.cjxq.value, bj: pro.bj.value.join(), kclb: pro.kclb.value.join(), kslb: pro.query.lx }, function (resultData) {
                        if (!resultData.ErrorMsg) {
                            pro.$notify({
                                title: '成功',
                                message: '操作成功',
                                type: 'success'
                            });
                            pro.querydata();
                            $('#DModal').modal('hide');
                        }
                    })
                }).catch(() => {

                });

            },
            querydata: function () {
                var pro = this;
                pro.loading = true;
                $.getJSON('/API/VIEWAPI.ashx?Action=KSGL_GETDBKSJ', { P1: "", xq: pro.query.xq.value, xb: pro.query.xb.value.join(), kslb: pro.query.lx.value, xiaoq: pro.query.xiaoq.value }, function (resultData) {
                    if (!resultData.ErrorMsg) {
                        pro.allxsdata = resultData.Result;
                        pro.allkcdata = resultData.Result1;
                        pro.loading = false;

                    }
                })

            },

            InitWigetData: function () {
                this.querydata();
            },
        },
        watch: {
            'query': { //深度监听，可监听到对象、数组的变化
                handler(newV, oldV) {
                    var chi = this;
                    if (newV) {
                        if (chi.query.xb.value.length > 0) {
                            chi.querydata();
                        }
                    }
                },
                deep: true
            }
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {           
                var sqdata = pro.$root.pagedata.ActionData;//授权列表
                if (sqdata == "生成名单") {
                    pro.isgly = true;
                }
            })

        }
    };
</script>